package com.ny.封装;

import java.util.ArrayList;
import java.util.List;

public class TestList {
    public void addEmp(Emp emp) {
        List<Emp> list = new ArrayList<>();
        list.add(emp);
    }

    public void findAllEmp(List<Emp> list){

        for (int i=0;i<list.size();i++){
            System.out.println(list.get(i));
        }
    }
    public Emp findEmpName(List<Emp> list,String ename){
        for (int j=0;j<list.size();j++){
            if (ename.equals(list.get(j).getName())){
                return list.get(j);
            }
        }return null;
    }
    public void deleteEmpNumber(List<Emp> list,String number){
        for (int k=0;k<list.size();k++){
            if (number.equals(list.get(k).getN())){
                list.remove(k);
                System.out.println(list);
            }
        }
    }
    public Emp findEmpNumber(List<Emp> list,String number){
        for (int n=0;n< list.size();n++){
            if (number.equals(list.get(n).getN())){
                return  list.get(n);
            }
        }return null;
    }
    public void updateEmpAge(List<Emp> list,Emp emp){
        for (int m=0;m< list.size();m++){
            if (emp.getN().equals(list.get(m).getN())){
                list.set(m,emp);
                System.out.println(list);
            }
        }
    }

    public Emp findTestNumber(List<Emp> list, String updateNumber) {
        return null;
    }
}
